<?php
/**
 * Created by PhpStorm.
 * User: yhg97p
 * Date: 2016/3/19
 * Time: 17:35
 */
namespace Admin\Controller;
use Think\Controller;
use Admin\Model\AuthRuleModel;
use Admin\Model\AuthGroupModel;
/**
 *
 *
 */
class UserInvestController extends AdminController {


    public function index(){
        $nickname       =   I('nickname');
        $map_list = array();
        if(!empty($nickname)){
            $map = array();
            $map['nickname']    =   array('like', '%'.(string)$nickname.'%');
            $user = M('User')->where($map)->find();
            $user_id = $user['id'];
            $map_list = array('user_id'=>$user_id);
        }

        $list = $this->lists('Invest', $map_list);
        int_to_string($list);
        $this->assign('_list', $list);
        $this->display();
    }
    //标记已还款
    public function repayment(){
        $id = array_unique((array)I('id',0));
        if( in_array(C('USER_ADMINISTRATOR'), $id)){
            $this->error("不允许对超级管理员执行该操作!");
        }
        $id = is_array($id) ? implode(',',$id) : $id;
        if ( empty($id) ) {
            $this->error('请选择要操作的数据!');
        }
        $map['id'] =   array('in',$id);
        M("Invest")->where($map)->save(array("repayment"=>"1"));
        $msg   = array( 'success'=>'操作成功！', 'error'=>'操作失败！', 'url'=>'' ,'ajax'=>IS_AJAX);
        $this->success($msg['success'],$msg['url'],$msg['ajax']);
    }
}